package com.ruoyi.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class UniqueCodeUtils {

    /**
     * 生成唯一号码
     * @param prefix 前缀
     * @return
     */
    public static String getUniqueCode(String prefix) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String dateFormat = sdf.format(new Date());
        String suffix = "";
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            suffix += random.nextInt(10);
        }
        return prefix + dateFormat + suffix;
    }
}
